<?php
class MoviesModel extends CI_Model {
	
	function getMovieDominan($genreid, $userid){
		$sql = "select MOVIEID from movies where (GENREID = $genreid and MOVIEID not in
				(select MOVIEID from rekomendasi where rekomendasi.USERID = $userid))";
		$data = $this->db->query($sql);
		return $data;		
	}

	
	function getAllMovie()
    {
        //$this->db->order_by('member_id');  //pengurutan berdasarkan id
        //return $this->db->get($this->table)->result();
//        $data = $this->db->query("select * from movies");
//        return $data;
		$sql = "select * from movies";
		$data = $this->db->query($sql);
		return $data;
    }
//	
//	function getMovieAwal($genreid){
//		$sql = "select MOVIEID from movies where GENREID = $genreid";
//		$data = $this->db->query($sql);
//		return $data;		
//	}

	
	function getMovie($genre, $userid){
		$sql = "select MOVIEID from movies where MOVIEID in (select MOVIEID from genres where GENRE = '$genre')
				and MOVIEID not in (select MOVIEID from rekomendasi where rekomendasi.USERID = $userid)";
		$data = $this->db->query($sql);
		return $data;		
	}
//	
	function getAllMovies(){
		$sql = "select * from movies where MOVIEID not in
				(select MOVIEID from movies where GENREID is not null)";
		$data = $this->db->query($sql);
		return $data;		
	}

	function getDataMovie($movieid){
		$sql = "select MOVIEID, TITLE, YEAR from movies where MOVIEID = $movieid";
		$data = $this->db->query($sql);
		return $data;
	}
	
//	function getDataMovie($movieid){
//		$sql = "select * from movies where MOVIEID = $movieid";
//		$data = $this->db->query($sql);
//		return $data;
//	}
	
}
?>